home *** CD-ROM | disk | FTP | other *** search
- Path: topaz.cqu.edu.au!naderr
- From: naderr@topaz.cqu.edu.au
- Newsgroups: comp.lang.c,comp.lang.c++
- Subject: sizeof() question >>> :)
- Date: 12 Apr 96 06:19:27 +1000
- Organization: Central Queensland University, Australia
- Message-ID: <1996Apr12.061927@topaz>
- NNTP-Posting-Host: topaz.cqu.edu.au
-
- Hi,
-
- How can I get, with a pointer, the sizeof of an array that is
- pointed by the pointer ? (No it's not a tounge twister :)
-
- Ok, let see if with an example I could clarify what I'm trying to say,
-
-
- char First_name[20];
- char Last_name[20];
- char Address[60];
- char Phone[20];
- char **ct, *cp;
- char *record[4];
- char ch;
-
- record[0] = First_name;
- record[1] = Last_name;
- record[2] = Address;
- record[3] = Phone;
- ct = record;
- cp = *ct;
-
- while (!done) {
- ch = getchar();
- if (cp - *ct < sizeof(XXXXXXX)-1) {
- *cp++ = ch;
- } else {
- beep();
- }
- }
-
- for XXXXXXX the _only_ thing that I can find that works is to stick
- in there is the actual array that cp is pointing to, i.e. sizeof(First_name).
-
- What ideas do you have so that I can get the size of the array currently
- pointed to by cp?
-
- Any ideas greatly appreciated,
-
- please email direct to me (as well if you wish to followup) at
-
- naderr@topaz.cqu.edu.au
-
- TIA,
-
- Rob
-
-
-